package org.tech4j.edi.api;

import org.tech4j.edi.common.entity.RetryBizConfig;
import org.tech4j.edi.common.entity.RetryBizRecord;
import org.tech4j.edi.common.result.EdiResult;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/7 09:55
 **/
public interface RetryRecordService {

    /**
     * 新增重试记录
     * @param retryBizRecord retryBizRecord
     * @return RetryBizConfig
     */
    EdiResult<String> addRetryRecord(RetryBizRecord retryBizRecord);


    /**
     * 新增重试记录, 并是否自动执行
     * @param retryBizRecord retryBizRecord
     * @param autoExe autoExe
     * @return RetryBizConfig
     */
    EdiResult<String> addRetryRecord(RetryBizRecord retryBizRecord, boolean autoExe);

    /**
     * 重试记录
     * @param idList id list
     * @param bizType biz type
     * @param startTime start time
     * @param force force
     * @return EdiResult
     */
    EdiResult<Void> retry(List<String> idList, String bizType, LocalDateTime startTime, boolean force);

    /**
     * 重试记录
     * @param retryBizRecordList RetryBizRecord list
     * @return EdiResult
     */
    EdiResult<Void> retry(List<RetryBizRecord> retryBizRecordList);

    /**
     * 关闭重试
     * @param id id
     * @param bizType biz type
     * @param startTime start time
     * @param remark remark
     * @return EdiResult
     */
    EdiResult<Void> close(String id, String bizType, LocalDateTime startTime, String remark);

    /**
     * 扫描重试记录
     * @param dateMonth dateMonth
     * @param startTime startTime
     * @param endTime endTime
     * @param index index
     * @param total total
     * @return EdiResult
     */
    default EdiResult<Void> scanRetry(String dateMonth, LocalDateTime startTime, LocalDateTime endTime, int index, int total) {
        return EdiResult.ofSuccess();
    }
}
